package ext.tianma.bom.expand.xls;

import wt.util.WTException;

/**
 * 类名: XlsReaderFactory </br>
 * 包名: ext.tianma.bom.expand.xls
 * 描述: 
 * @author xucr
 * 创建时间: 2020年6月1日
 * 发布版本: V1.0
 */
public class XlsReaderFactory
{

	private static XlsReader xlsReaderService;
	
	public  XlsReader getDefault(){
		return xlsReaderService;		
	}
	
	private static volatile XlsReaderFactory factory = null;
	
	
	static {
		try
		{
			XlsReaderFactory factory = XlsReaderFactory.getInstance();
			xlsReaderService = factory.getXlsReaderService(XlsReaderDefaultImpl.class);	//提供默认实现
		} catch (WTException e)
		{
			e.printStackTrace();
		}
	}
	
	public static XlsReaderFactory  getInstance(){
		
		if(factory==null){
			synchronized(XlsReaderFactory.class){
				if(factory==null){
					factory = new XlsReaderFactory();
				}
			}
		}
		return factory;
	}
	
	/**
	 * 获取实现类
	 * @author zhen.chen
	 * @param implClz
	 * @return reader
	 * @throws WTException
	 */
	public XlsReader getXlsReaderService(Class<?> implClz) throws WTException{
		try
		{
			XlsReader reader = (XlsReader)implClz.newInstance();
			return reader;
		} catch (Exception e)
		{
			e.printStackTrace();
			throw new WTException(e);
		} 
	}
}
